<include file="public@header">
<link rel="stylesheet" type="text/css" href="__STATIC__/layui/css/layui.css">
<style>
    .alertaddress{
        position: fixed;
        left: 0;
        top: 0;
        background: #1f1e24;
        z-index: 99;
        width: 100%;
        height: 100vh;
        overflow-y: scroll;
        padding-bottom: 2rem;
        box-sizing: border-box;
        display: none;
    }   
    
    .addressbtn{
        width: 6.9rem;
        position: absolute;
        position: fixed;
        bottom: 0.5rem;
        left: 0.3rem;
        margin: 0;
    }
    .addressshow{
/*        border-bottom: 1px solid #eee;*/
        background: #1f2630;
    }
    
    .layui-layer-shade{
        background-color:transparent;
        background-image: linear-gradient(to top, rgb(237,190,58), transparent)!important;
        opacity: 1!important;
    }
    .layui-layer{
        background: #1f2630;
    }
    .layui-layer-title{
        background: #1f2630;
        border-bottom:0;
        color: #fff;
        font-weight: bold;
    }
    .layui-layer-prompt .layui-layer-input{
        width: 100%;
        height: 0.7rem;
        border-radius: 0.08rem;
        margin-top: 0.3rem;
        background: #29313e;
        outline: none;
        border: 0;
        font-size: 0.3rem;
        padding-left: 0.3rem;
        line-height: 0.7rem;
        box-sizing: border-box;
        border: 0.02rem solid #eebd3a;
        color: #fff;
    }
    .layui-layer-btn .layui-layer-btn0{
        background: transparent;
        color: #26db8e;
        border: 0;
    }
    .layui-layer-btn .layui-layer-btn1{
        background: transparent;
        color: #ff3300;
        border: 0;
    }
    .agojilu{
        display: block;
        width: 0.22rem;
        height: 0.26rem;
        position: absolute;
        top: 0.29rem;
        right: 0.3rem;
        z-index: 1000;
    }
    .agojilu>img{
        width: 100%;
    }
    .layui-layer-content{
        color:#fff;
    }
</style>
<body>
    <a href="{:url('user/zichan/record',array('act'=>'2'))}" class="agojilu"><img src="__STATIC__/hybit/images/jilu.png" alt="" /></a>
    <div class="bgbg headhead">
        <form action="" method="post" class="layui-form">
        <h3 class="mytitle">{:lang('Withdraw')}</h3>
        <div class="tb">
            <div class="zz_tb">
                <div class="tbhead alias">
                    <foreach name="alias_list" item="vo">
                        <div class="<if $key == 0>active</if>" data-sxf="{$vo.sxf}" data-min="{$vo.min}">{$vo.alias}</div>
                    </foreach>
                    <div class="" data-sxf="10" data-min="50">账号转账</div>
                </div>
                <div class="tbinput">
                    <p>{:lang('Withdraw Address')}|账号</p>
                    <div class="tbinf">
                        <input id="address" name="address" type="text" placeholder="{:lang('Enter or paste address')}|账号">
                        <img src="__STATIC__/hybit/images/saoma.png" alt="" class="saomaimg" style="display:none;">
                        <img src="__STATIC__/hybit/images/address.png" alt="" class="addressimg" style="margin-left:auto;">
                    </div>
                </div>
                <div class="tbinput">
                    <p>{:lang('Num')}</p>
                    <div class="tbinf tbinfnum">
                        <input type="text" name="number" placeholder="{:lang('Num')}">
                        <input type="hidden" name="symbol" value="USDT_ERC20">
                        <p><span id="ad">USDT_ERC20</span><i onclick="allbalance()">&nbsp;&nbsp;|&nbsp;&nbsp;{:lang('All')}</i></p>
                    </div>
                </div>
                <div class="tbhead tbinput code">
                    <div class="active" data-type="mobile">{:lang('mobile')}</div>
                    <div class="" data-type="email">{:lang('email')}</div>
                </div>
                <div class="infshow infyzm tbinput">
                    <p>{:lang('Code')}</p>
                    <input type="text" name="code" placeholder="{:lang('Please enter code')}">
                    <button type="button" class="infyzmbtn">{:lang('Get code')}</button>
                </div>
                <div class="tbnote">
                    <p class="tbnote1">{:lang('Available')}：{:floatval($user.balance)} USDT</p>
                    <p class="tbnote2">{:lang('Fee')}</p>
                    <p class="tbnote3"><i id="sxf"></i><span>USDT</span></p>
                </div>
                <div class="cbnote">
                    <h3 class="tbnoteh3">*{:lang('Prompt')}</h3>
                    <p>{:lang('Minimum Withdraw amount')}:<i id="min"></i>USDT</p>
                </div>
                <div style="padding: 0 0.25rem">
            <button type="button" class="loginbtn" lay-submit>{:lang('Withdraw')}</button>
        </div>
            </div>
        </div>
        <input type="hidden" name="tx_sxf">
        <input type="hidden" name="tx_min">
        <input type="hidden" name="type" value="mobile">
        </form>
    </div>

    <div class="alertaddress">
        <div class="addressall">
            <foreach name="list" item="vo">
            <div class="addressshow">
                <p class="addressshowp1"><span>USDT</span>{$vo.remark}</p>
                <div class="addressshow2">
                    <input type="text" value="{$vo.address}">
                </div>
            </div>
            </foreach>
        </div> 
        
        <button type="button" class="loginbtn addressbtn" onclick="hidealert()">{:lang('Cancel')}</button>
    </div>
    <script src="__STATIC__/hybit/js/jquery.min.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script>
        $('.code div').click(function(){
            let $this = $(this);
            $this.siblings('div').removeClass('active');
            $this.addClass('active');
            $('input[name=type]').val($this.data('type'));
        });
    
        var son = '{$son.id}';
        console.log(son);

        $('#sxf').html($('.alias .active').attr('data-sxf'));
        $('#min').html($('.alias .active').attr('data-min'));
        $('input[name=tx_sxf]').val($('.alias .active').attr('data-sxf'));
        $('input[name=tx_min]').val($('.alias .active').attr('data-min'));
        $('.alias div').click(function(){
            let $this = $(this);
            $this.siblings('div').removeClass('active');
            $this.addClass('active');
            $('input[name=symbol]').val($this.html());
            $('#ad').html($this.html());
            $('#sxf').html($this.data('sxf'));
            $('#min').html($this.data('min'));
            $('input[name=tx_sxf]').val($this.data('sxf'));
            $('input[name=tx_min]').val($this.data('min'));
        });
        
        $('.addressimg').click(function(){
            $('.alertaddress').show();
        })
        
        $('.addressshow').click(function(){
             $('#address').val($(this).find('input').val());
             $('.alertaddress').hide();
        })
        
        function hidealert(){
            $('.alertaddress').toggle();
        }

        function allbalance()
        {
            $('input[name=number]').val('{:floatval($user.balance)}');
        }

        layui.use(['form','layer'],function(){
            var layer = layui.layer,
                form = layui.form;

            $('.infyzmbtn').click(function(){
                var obj = $(this);
                var type = $('input[name=type]').val();
                $(obj).attr('disabled', true);
                $.ajax({
                    type: 'get',
                    url: '{:url("zichan/send")}',
                    data: {type:type},
                    success:function(res){
                        layer.msg(res.msg)
                        if(res.code == 1){
                            let count = 60;
                            const countDown = setInterval(() => {
                            if (count === 0) {
                            $(obj).text('{:lang("Resend")}').removeAttr('disabled');
                            clearInterval(countDown);
                            } else {
                               $(obj).text(count + 's');
                            }
                            count--;
                            }, 1000);
                        }else{
                            $(obj).text('{:lang("Resend")}').removeAttr('disabled');
                        }
                    }
                });
            });


            if(son){
                //layer.alert('您的账号已开通子账户功能，如若申请提现将自动解绑与主账号的关联！');
                layer.open({
                    title: false,
                    content: '您的账号已开通子账户功能，如若申请提现将自动解绑与主账号的关联！'
                }); 
            }

            //监听提交
            form.on('submit', function(data){
                var _this = $(this);
                //输入资金密码
                layer.prompt({title:'{:lang("Please enter the fund password")}'},function(value, index, elem){
                    _this.attr("disabled",true);
                    layer.close(index);
                    $.ajax({
                        type: 'post',
                        url: '{:url("user/zichan/verification_password")}',
                        data: {password:value},
                        success:function(result){
                            if(result.code == 1){
                                $.ajax({
                                    type: 'post',
                                    url: '{:url("user/zichan/tixian")}',
                                    data: data.field,
                                    success:function(res){
                                        layer.msg(res.msg)
                                        if(res.code == 1){
                                            setTimeout(function(){ javascript:history.back(-1); }, 1500);
                                        }else{
                                            _this.removeAttr("disabled");
                                        }
                                    }
                                });
                            }else{
                                layer.msg(result.msg);
                                _this.removeAttr("disabled");
                            }
                        }
                    });
                });
                return false;
            });
        });
    </script>
</body>
</html>